import java.util.concurrent.TimeUnit;

import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;




public class FileMonitorTest {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		 String dir = "d:/temp";
		 long interval = TimeUnit.SECONDS.toMillis(5);
		 //FileAlterationObserver observer = new FileAlterationObserver(dir,FileFilterUtils.and(FileFilterUtils.fileFileFilter(),FileFilterUtils.suffixFileFilter(".java")), null);
		 FileAlterationObserver observer = new FileAlterationObserver(dir);
		 observer.addListener(new ScanFile());
		 observer.checkAndNotify();
		 FileAlterationMonitor monitor = new FileAlterationMonitor(interval,observer);
		 monitor.start();
	}

}
